<meta charset="UTF-8" />
<title>下载桌面快捷方式</title>

地址：<input id="urlInput" value="https://www.baidu.com/" />
<br />
<br />
文件名：<input id="nameInput" value="百度一下" />
<br />
<br />
<button id="downloadButton">下载快捷方式</button>

<script type="module">
    import textToFile from "../utils/convert/text-to-file.js";
    import downloadFile from "../utils/download/download-file.js";

    /** @type { HTMLInputElement } */ const urlInput = document.querySelector("#urlInput");
    /** @type { HTMLInputElement } */ const nameInput = document.querySelector("#nameInput");
    /** @type { HTMLButtonElement } */ const downloadButton = document.querySelector("#downloadButton");

    downloadButton.onclick = function() {

        const url = urlInput.value;
        const name = nameInput.value;

        const fileContent = "[{000214A0-0000-0000-C000-000000000046}]" + "\r\n"
            + "Prop3=19,2" + "\r\n"
            + "[InternetShortcut]" + "\r\n"
            + "IDList=" + "\r\n"
            + "URL=" + url  + "\r\n"
        ;

        downloadFile(textToFile(name + ".url", fileContent));
    };

</script>
